package cc.rengu.oltp.service.common.enums;

/**
 * 订单状态枚举
 * Created by 王成 on 2020/2/21.
 */
public enum OrderStatusEnum {
    INIT("00", "新建订单"),
    CLOSE("01", "订单已关闭"),
    INVALID("02", "订单已过期"),
    FINISH("03", "订单已支付");
    private String status;
    private String desc;

    OrderStatusEnum(String status, String desc) {
        this.status = status;
        this.desc = desc;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 根据错误状态码获取订单状态枚举
     *
     * @param status 订单状态
     * @return 订单状态枚举
     */
    public static OrderStatusEnum getOrderStatusEnum(String status) {
        for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
            if (status.equals(orderStatusEnum.getStatus())) {
                return orderStatusEnum;
            }
        }
        return null;
    }
}
